package cn.fl.changeapply.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.utils.*;
import cn.fl.capital.condition.CapPayInfoQueryCondition;
import cn.fl.capital.condition.CapPayeeInfoQueryCondition;
import cn.fl.capital.constant.CapPayInfoConstant;
import cn.fl.capital.constant.CapPayeeInfoConstant;
import cn.fl.capital.constant.CapitalConstant;
import cn.fl.capital.service.ICapFundService;
import cn.fl.capital.service.ICapPayInfoService;
import cn.fl.capital.service.ICapPayeeInfoService;
import cn.fl.capital.vo.CapFundVO;
import cn.fl.capital.vo.CapPayInfoVO;
import cn.fl.capital.vo.CapPayeeInfoVO;
import cn.fl.changeapply.api.IPrjPrdChangeApplyApiService;
import cn.fl.changeapply.condition.PrjPrdChangeApplyQC;
import cn.fl.changeapply.constant.PrjPrdChangeApplyConstant;
import cn.fl.changeapply.dto.PrjPrdChangeApplyDTO;
import cn.fl.changeapply.service.IPrjPrdChangeApplyService;
import cn.fl.changeapply.transform.PrjPrdChangeApplyVOTransform;
import cn.fl.changeapply.vo.PrjPrdChangeApplyFlowVO;
import cn.fl.changeapply.vo.PrjPrdChangeApplyVO;
import cn.fl.customer.service.ICstBscInfoService;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.insurance.constant.InsuranceConstant;
import cn.fl.project.condition.PrjPrdPaySchDQueryCondition;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.project.constant.PrjPrdDtlConstant;
import cn.fl.project.constant.PrjPrdPaySchMConstant;
import cn.fl.project.dto.PrjPrdPaySchDDTO;
import cn.fl.project.service.*;
import cn.fl.project.vo.*;
import cn.fl.system.constant.SysLogConstant;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.flow.facade.flow.api.IFlowQueryApiService;
import fl.flow.facade.flow.condition.SysFlowSHQueryCondition;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.SysFlowSHDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 退车审批流程 控制层
 *
 * @author gaohongying
 */
@Controller
@RequestMapping("/changeApply/flow")
public class PrjPrdChangeApplyFlowController extends BaseController {

    @Autowired
    private IPrjPrdChangeApplyService prjPrdChangeApplyService;

    @Autowired
    private ICapPayInfoService capPayInfoService;

    @Autowired
    private ICapPayeeInfoService capPayeeInfoService;

    @Autowired
    private IPrjPrdLicInfoService prjPrdLicInfoService;

    @Autowired
    private IPrjPrdMtgService prjPrdMtgService;

    @Autowired
    private IPrjBscInfoService prjBscInfoService;

    @Autowired
    private IPrjPrdPaySchMService prjPrdPaySchMService;

    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService;

    @Autowired
    private ICapFundService capFundService;

    @Autowired
    private ICstBscInfoService cstBscInfoService;

    @Autowired
    private IPrjPrdChangeApplyApiService prjPrdChangeApplyApiService;

    @Autowired
    private IPrjPaySchDApiService prjPaySchDApiService;

    @Autowired
    private IPrjPrdDtlService prjPrdDtlService;

    @Autowired
    private IFlowQueryApiService flowQueryApiService;

    /**
     * 到退车审批流程附加信息页面
     */
    @RequestMapping(value = "/toAdditionalInfoPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAdditionalInfoPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.newLogger("到退车审批流程附加信息页面").setKeys("toAdditionalInfoPage", CurrentThreadContext.getCurrentUserName()).info();
        ModelAndView view = new ModelAndView("changeapply/prjPrdChangeApply/prjPrdChangeApplyFlowPage");
        String changeApplyId = request.getParameter("changeApplyId");//业务主键
        String proIntId = request.getParameter("processInstanceId");//流程实例ID
        String taskId = request.getParameter("taskId");//任务ID
        String taskDefKey = request.getParameter("taskDefKey");//任务KEY
        String taskNm = request.getParameter("taskNm");//任务名称
        String procNm = request.getParameter("procNm");//流程名称
        String isDetail_bk = request.getParameter("isDetail_bk");//标识是否详情(客户付款信息/我司收款信息)
        String ctrlKey = request.getParameter("ctrlKey");//控制键 1.可上传、删除 2.可上传合同 3.不可操作
        String fundInfoFlag = request.getParameter("fundInfoFlag");//资金基本信息是否展示
        String updInfoFlag = request.getParameter("updInfoFlag");//申请信息是否可修改
        String isSqSubmitFlag = request.getParameter("isSqSubmitFlag");//是否我司报送展示

        try {
            view.addObject("changeApplyId", changeApplyId);
            view.addObject("proIntId", proIntId);
            view.addObject("taskId", taskId);
            view.addObject("taskDefKey", taskDefKey);
            view.addObject("taskNm", taskNm);
            view.addObject("procNm", procNm);
            view.addObject("isDetail_bk", isDetail_bk);
            view.addObject("ctrlKey", ctrlKey);
            view.addObject("fundInfoFlag", fundInfoFlag);
            view.addObject("updInfoFlag", updInfoFlag);
            view.addObject("isSqSubmitFlag", isSqSubmitFlag);
            view.addObject("currentUsrId", CurrentThreadContext.getCurrentUserId());
            if (StringUtils.isEmpty(changeApplyId)) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "流程中业务主键为空.");
            }

            //查询退车申请信息
            BaseLogUtils.newServiceLogger("===退车审批流程查询付款信息Start===changeApplyId:" + changeApplyId).info();
            PrjPrdChangeApplyVO prjPrdChangeApplyVO = prjPrdChangeApplyService.selectById(Long.valueOf(changeApplyId));
            BaseLogUtils.newServiceLogger("===退车审批流程查询付款信息End===changeApplyId:" + changeApplyId + ",prjPrdChangeApplyVO:" + JSON.toJSONString(prjPrdChangeApplyVO)).info();

            //查询项目信息
            BaseLogUtils.newLogger("===退车申请查询项目信息Start===prjId:{}", prjPrdChangeApplyVO.getPrjId()).info();
            PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(prjPrdChangeApplyVO.getPrjId());
            BaseLogUtils.newLogger("===退车申请查询项目信息End===prjId:{},vo:{}", prjPrdChangeApplyVO.getPrjId(), JSON.toJSONString(prjBscInfoVO)).info();
            view.addObject("prjBscInfoVO", prjBscInfoVO);

            //查询付款表信息
            Long prjPrdDtlId = prjPrdChangeApplyVO.getPrjPrdDtlId();
            //实际放款时间
            CapPayInfoQueryCondition payInfoQueryCondition = new CapPayInfoQueryCondition();
            payInfoQueryCondition.setPrjPrdDtlId(prjPrdDtlId);
            BaseLogUtils.newLogger("===退车申请查询付款信息Start===prjPrdDtlId:" + prjPrdDtlId).info();
            List<CapPayInfoVO> payList = this.capPayInfoService.searchList(payInfoQueryCondition);
            if (CollectionUtils.isEmpty(payList)) {
                payInfoQueryCondition.setIsDel(BaseConstant.IS_YESNO_YES);
                payList = this.capPayInfoService.searchList(payInfoQueryCondition);
            }
            BaseLogUtils.newLogger("===退车申请查询付款信息End===prjPrdDtlId:{},list:{}", prjPrdDtlId, JSON.toJSONString(payList)).info();
            CapPayInfoVO capPayInfoVO = null;
            if (CollectionUtils.isNotEmpty(payList)) {
                capPayInfoVO = payList.get(0);
                view.addObject("capPayInfoVO", capPayInfoVO);

                //查询付款表明细信息
                CapPayeeInfoQueryCondition qc = new CapPayeeInfoQueryCondition();
                qc.setPayId(capPayInfoVO.getId());
                List<String> purpCds = new ArrayList<>();
                purpCds.add(CapPayeeInfoConstant.CODE_PURP_CD_00000008_1);
                purpCds.add(CapPayeeInfoConstant.CODE_PURP_CD_00000008_11);
                purpCds.add(CapPayeeInfoConstant.CODE_PURP_CD_00000008_2);//供应商返利
                qc.setPurpCds(purpCds);
                BaseLogUtils.newLogger("===退车申请查询收款信息Start===payId:{},qc:{}", capPayInfoVO.getId(), JSON.toJSONString(qc)).info();
                List<CapPayeeInfoVO> capPayeeInfoVOS = this.capPayeeInfoService.searchList(qc);
                BaseLogUtils.newLogger("===退车申请查询收款信息End===payId:{},size:{}", capPayInfoVO.getId(), capPayeeInfoVOS == null ? 0 : capPayeeInfoVOS.size()).info();
                if (CollectionUtils.isEmpty(capPayeeInfoVOS)) {
                    qc.setIsDel(BaseConstant.IS_YESNO_YES);
                    capPayeeInfoVOS = this.capPayeeInfoService.searchList(qc);
                    BaseLogUtils.newLogger("===退车申请查询收款信息End===payId:{},size:{}", capPayInfoVO.getId(), capPayeeInfoVOS == null ? 0 : capPayeeInfoVOS.size()).info();
                }
                if (CollectionUtils.isNotEmpty(capPayeeInfoVOS)) {
                    //放款金额
                    Long actPayAmt = 0l;
                    //供应商返利
                    Long rebateAmt = 0l;
                    //销售返利
                    Long saleActPayAmt = 0l;
                    for (CapPayeeInfoVO vo : capPayeeInfoVOS) {
                        if (CapPayeeInfoConstant.CODE_PURP_CD_00000008_1.equals(vo.getPurpCd())) {
                            //实际放款时间
                            Date actPayTm = vo.getActPayTm();
                            if (actPayTm != null) {
                                view.addObject("actPayTm", DateUtils.formatDateToString(actPayTm, DateUtils.YYYY_MM_DD));
                            }
                            //放款金额
                            if (vo.getActPayAmt() != null) {
                                actPayAmt = vo.getActPayAmt();
                                view.addObject("actPayAmt", vo.getActPayAmt());
                            }
                        } else if (CapPayeeInfoConstant.CODE_PURP_CD_00000008_11.equals(vo.getPurpCd())) {
                            //销售返利
                            if (vo.getActPayAmt() != null) {
                                saleActPayAmt = vo.getActPayAmt();
                                view.addObject("saleActPayAmt", vo.getActPayAmt());
                            }
                        } else if (CapPayeeInfoConstant.CODE_PURP_CD_00000008_2.equals(vo.getPurpCd())) {
                            //供应商返利
                            if (vo.getActPayAmt() != null) {
                                rebateAmt = vo.getActPayAmt();
                                view.addObject("rebateAmt", vo.getActPayAmt());
                            }
                        }
                    }
                    //财务节点重新计算一下是否有返利信息
                    if ("FLOW_0000_073_001_002".equals(taskDefKey) || "FLOW_0000_073_001_006".equals(taskDefKey)) {
                        if (rebateAmt > 0l || saleActPayAmt > 0l) {
                            //应收款金额
                            double recAmount = 0d;
                            //应收款金额=放款金额+资金占用成本+供应商返利+销售返利
                            Long fundOccCost = prjPrdChangeApplyVO.getFundOccCost() == null ? 0 : prjPrdChangeApplyVO.getFundOccCost();
                            recAmount = DecimalUtils.add(DecimalUtils.add(DecimalUtils.add(actPayAmt, fundOccCost), rebateAmt), saleActPayAmt);
                            Long recAmountL = new Double(recAmount).longValue();
                            if (!recAmountL.equals(prjPrdChangeApplyVO.getRecAmount())) {
                                //若不相等，即之前没有返利，现在存在返利，则修改应收款金额
                                prjPrdChangeApplyVO.setRecAmount(recAmountL);
                                BaseLogUtils.newLogger("toAdditionalInfoPage.修改退车审批记录Start.id:{},entity:{},userNm:{}", changeApplyId, JSON.toJSONString(prjPrdChangeApplyVO), CurrentThreadContext.getCurrentUserName()).info();
                                boolean success = this.prjPrdChangeApplyService.modify(prjPrdChangeApplyVO);
                                BaseLogUtils.newLogger("toAdditionalInfoPage.修改退车审批记录End.id:{},success:{},userNm:{}", changeApplyId, success, CurrentThreadContext.getCurrentUserName()).info();
                                if (!success) {
                                    BaseLogUtils.newLogger("toAdditionalInfoPage.修改退车审批记录失败.id:{},entity:{},userNm:{}", changeApplyId, JSON.toJSONString(prjPrdChangeApplyVO), CurrentThreadContext.getCurrentUserName()).info();
                                    throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "修改退车审批记录失败.");
                                }
                            }
                        }
                    }
                }
            }
            //申请日期(类型转换)
            if (prjPrdChangeApplyVO.getCrtTm() != null) {
                prjPrdChangeApplyVO.setCrtTmStr(DateUtils.formatDateToString(prjPrdChangeApplyVO.getCrtTm(), DateUtils.YYYY_MM_DD));
            }
            //应收款金额(类型转换)
            if (prjPrdChangeApplyVO.getRecAmount() != null) {
                prjPrdChangeApplyVO.setRecAmounts(DecimalUtils.convertFenToYuan(prjPrdChangeApplyVO.getRecAmount()));
            }

            //查询启用支付表
            BaseLogUtils.newLogger("===退车申请查询支付表信息Start===paySchId:{}", prjPrdChangeApplyVO.getPaySchId()).info();
            PrjPrdPaySchMVO prjPrdPaySchMVO = prjPrdPaySchMService.selectByIdWithoutDel(prjPrdChangeApplyVO.getPaySchId());
            BaseLogUtils.newLogger("===退车申请查询支付表信息End===paySchId:{},vo:{}", prjPrdChangeApplyVO.getPaySchId(), JSON.toJSONString(prjPrdPaySchMVO)).info();
            if (prjPrdPaySchMVO == null) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "支付表信息为空.");
            }

            //起租日类型转换
            if (prjPrdPaySchMVO.getLsDt() != null) {
                prjPrdPaySchMVO.setLsDts(DateUtils.formatDateToString(prjPrdPaySchMVO.getLsDt(), DateUtils.YYYY_MM_DD));
            }

            //三方资管放款状态
            Map<String, String> thirdCapStsCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_THIRD_CAP_STS_CD);
            if (thirdCapStsCdMap != null) {
                prjPrdPaySchMVO.setPayerStsCdNm(thirdCapStsCdMap.get(prjPrdPaySchMVO.getPayerStsCd()));
            }
            //是否我司报送
            String isSqSubmit = "否";
            if ("1".equals(isSqSubmitFlag)) {
                Integer isSqBiz = prjPrdPaySchMVO.getIsSqBiz();
                Integer isSubmitCredit = prjPrdPaySchMVO.getIsSubmitCredit();
                if (isSqBiz != null && isSqBiz == BaseConstant.IS_YESNO_YES && isSubmitCredit != null && isSubmitCredit == BaseConstant.IS_YESNO_YES) {
                    isSqSubmit = "是";
                }
            }
            view.addObject("isSqSubmit", isSqSubmit);

            //租赁年利率：取值为项目支付表中租赁年利率；若当前资产启用为赎回支付表，则取值我司支付表中租赁年利率
            if (PrjPrdPaySchMConstant.PAY_SCH_TYP_CD_SH.equals(prjPrdPaySchMVO.getPaySchTypCd())
                    || PrjPrdPaySchMConstant.PAY_SCH_TYP_CD_SH.equals(prjPrdChangeApplyVO.getPaySchTypCd())) {
                if (capPayInfoVO != null) {
                    PrjPrdPaySchMVO prdPaySchMVO = prjPrdPaySchMService.selectByIdWithoutDel(capPayInfoVO.getPaySchId());
                    if (prdPaySchMVO == null) {
                        throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "我司支付表信息为空.");
                    }
                    prjPrdPaySchMVO.setAnnIntRatePct(prdPaySchMVO.getAnnIntRatePct());
                }
            }
            //处理年利率比例小数位
            if (null != prjPrdPaySchMVO.getAnnIntRatePct()) {
                prjPrdPaySchMVO.setAnnIntRatePct(DecimalUtils.round(prjPrdPaySchMVO.getAnnIntRatePct(), 2));
            }
            //上牌状态
            String spStateNm = "未上牌";
            //抵押状态
            String dyStateNm = "未抵押";
            BaseLogUtils.newServiceLogger("===退车审批流程查询上牌抵押信息Start===prjPrdDtlId:" + prjPrdDtlId).info();
            if (StringUtils.isNotEmpty(prjPrdDtlId)) {
                //上牌状态
                PrjPrdLicInfoVO prjPrdLicInfoVO = this.prjPrdLicInfoService.selectById(prjPrdDtlId);
                BaseLogUtils.newServiceLogger("===退车审批流程查询上牌信息End===prjPrdDtlId:" + prjPrdDtlId + ",prjPrdLicInfoVO:" + JSON.toJSONString(prjPrdLicInfoVO)).info();
                if (null != prjPrdLicInfoVO && FlowConstant.FLOW_CHECK_STATE_PASS.equals(prjPrdLicInfoVO.getAudStsCd())) {
                    spStateNm = "已上牌";
                }
                //抵押状态
                PrjPrdMtgVO prjPrdMtgVO = this.prjPrdMtgService.selectById(prjPrdDtlId);
                BaseLogUtils.newServiceLogger("===退车审批流程查询抵押信息End===prjPrdDtlId:" + prjPrdDtlId + ",prjPrdMtgVO:" + JSON.toJSONString(prjPrdMtgVO)).info();
                if (null != prjPrdMtgVO && StringUtils.isNotEmpty(prjPrdMtgVO.getGuarStsCd())) {
                    Map<String, String> guarStsMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.CODE_GUAR_STS_CD);//抵押状态
                    if (guarStsMap != null && guarStsMap.containsKey(prjPrdMtgVO.getGuarStsCd())) {
                        dyStateNm = guarStsMap.get(prjPrdMtgVO.getGuarStsCd());
                    }
                }
            }
            view.addObject("prjPrdChangeApplyVO", prjPrdChangeApplyVO);
            view.addObject("paySchId", prjPrdChangeApplyVO.getPaySchId());
            view.addObject("spStateNm", spStateNm);
            view.addObject("dyStateNm", dyStateNm);
            view.addObject("prjPrdPaySchMVO", prjPrdPaySchMVO);
        } catch (NumberFormatException e) {
            BaseLogUtils.newLogger("===toAdditionalInfoPage跳转退车审批流程页面BASE异常===Detail:" + e).setBussinessId(changeApplyId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
            e.printStackTrace();
        } catch (Exception e) {
            BaseLogUtils.newLogger("===toAdditionalInfoPage跳转退车审批流程页面BASE异常===Detail:" + e).setBussinessId(changeApplyId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
            e.printStackTrace();
        }
        BaseLogUtils.newLogger("toAdditionalInfoPage退车审批流程页面.返回前台.view:" + JSON.toJSONString(view)).info();
        return view;
    }

    /**
     * 资管结清
     *
     * @param request
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/toAddCapFundPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddCapFundPage(HttpServletRequest request) throws BaseException {
        BaseLogUtils.newLogger("toAddCapFundPage退车审批流程资管结清页面." + CurrentThreadContext.getCurrentUserName()).info();
        ModelAndView mav = new ModelAndView("capital/capFund/capFundAddBind");
        // 业务主键：结清->启用支付表ID
        String dataId = request.getParameter("dataId");
        // 项目ID
        String prjId = request.getParameter("prjId");
        if (StringUtils.isEmpty(dataId) || StringUtils.isEmpty(prjId)) {
            BaseLogUtils.newLogger("toAddCapFundPage退车审批流程资管结清页面.业务主键或项目ID为空." + CurrentThreadContext.getCurrentUserName()).info();
            return mav;
        }
        Long paySchId = Long.parseLong(dataId);

        List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();
        mav.addObject("fundBelongOrgCdList", JSON.toJSONString(orgList));

        //查询支付表信息
        PrjPrdPaySchMVO paySchMVO = this.prjPrdPaySchMService.selectById(paySchId);
        if (paySchMVO == null) {
            BaseLogUtils.newLogger("toAddCapFundPage退车审批流程资管结清页面.未找到支付表信息.dataId:" + dataId).info();
            return mav;
        }
        //查询项目信息
        PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.parseLong(prjId));
        if (prjBscInfoVO == null) {
            BaseLogUtils.newLogger("toAddCapFundPage退车审批流程资管结清页面.未找到项目信息.dataId:" + dataId).info();
            return mav;
        }

        CapFundVO fundVO = new CapFundVO();
        fundVO.setRelationPayId(paySchId);//资金管理关联业务ID
        fundVO.setIdentifyOperator(CurrentThreadContext.getCurrentUserId());//认款人ID
        fundVO.setIdentifyOperatorNm(CurrentThreadContext.getCurrentUserName());//认款人名称
        fundVO.setIdentifyTime(new Date());//认款时间 add时会修改
        fundVO.setAcceptName(InsuranceConstant.CODE_FC_ACCEPT_ACCOUNT_NM);//收款账户
        fundVO.setAcceptCode(InsuranceConstant.CODE_FC_ACCEPT_ACCOUNT_CD);//收款账号
        fundVO.setPaySchNo(paySchMVO.getPaySchNo());
        fundVO.setCstId(paySchMVO.getCstId());
        fundVO.setCstNm(prjBscInfoVO.getCstNm());
        fundVO.setFundBelongOrgCd(prjBscInfoVO.getBuOrgCd());
        fundVO.setComeName(prjBscInfoVO.getCstNm());
        //交易日期与实际到账日期默认流程发起时间
        Date flowStartTm = this.capFundService.getFlowStartTime(paySchId, CapitalConstant.CODE_BIZ_TYP_CD_3);
        if (null != flowStartTm) {
            fundVO.setAcceptDate(DateUtils.formatDate(flowStartTm, DateUtils.YYYY_MM_DD));
            fundVO.setAcceptActualDate(DateUtils.formatDate(flowStartTm, DateUtils.YYYY_MM_DD));
            fundVO.setAcceptDates(DateUtils.formatDateToString(fundVO.getAcceptDate(), DateUtils.YYYY_MM_DD));
            fundVO.setAcceptActualDates(DateUtils.formatDateToString(fundVO.getAcceptActualDate(), DateUtils.YYYY_MM_DD));
        }

        mav.addObject("paySchId", paySchId);
        mav.addObject("cstId", fundVO.getCstId());
        mav.addObject("cstNm", prjBscInfoVO.getCstNm());
        mav.addObject("capFundVO", fundVO);
        mav.addObject("stlDtDisableFlag", 0);// 结清时间是否显示，0-否，1-是
        return mav;
    }

    /**
     * 发起退车审批流程
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/changeApplyFlowStart.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object changeApplyFlowStart(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "流程发起成功！");
        PrjPrdChangeApplyVO entity = null;
        try {
            entity = this.getRequestParamForChangeApply(request);
            if (entity == null) {
                result = new DataResultVO(BaseConstant.IS_YESNO_NO, SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
                BaseLogUtils.newWebLogger("changeApplyFlowStart.发起流程==参数为空!" + "userNm:" + CurrentThreadContext.getCurrentUserName()).info();
                return result;
            }
            BaseLogUtils.newWebLogger("changeApplyFlowStart.发起流程Start=prjId:" + entity.getPrjId() + ",userNm:" + CurrentThreadContext.getCurrentUserName()).info();
            PrjPrdChangeApplyDTO prjPrdChangeApplyDTO = PrjPrdChangeApplyVOTransform.toDTO(entity);
            //流程发起人及组织架构取当前人
            prjPrdChangeApplyDTO.setCrtUsrName(CurrentThreadContext.getCurrentUserName());
            prjPrdChangeApplyDTO.setCurrentOrgCd(CurrentThreadContext.getCurrentOrgCd());
            prjPrdChangeApplyDTO.setCurrentBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
            prjPrdChangeApplyDTO.setCurrentUsrId(CurrentThreadContext.getCurrentUserId());
            prjPrdChangeApplyDTO.setCurrentUsrNm(CurrentThreadContext.getCurrentUserName());
            prjPrdChangeApplyDTO.setCurrentSysCd(CurrentThreadContext.getCurrentSysCd());
            DataResultDTO resultDTO = this.prjPrdChangeApplyApiService.addChangeApplyFlow(prjPrdChangeApplyDTO);
            BaseLogUtils.newLogger("changeApplyFlowStart.发起流程End=prjId:{},resultDTO:{},userNm:{}", entity.getPrjId(), JSON.toJSONString(resultDTO), CurrentThreadContext.getCurrentUserName()).info();
            result.setSuccess(resultDTO.getSuccess());
            result.setInfo(resultDTO.getInfo());
        } catch (BaseException e) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(e.getMessage());
            BaseLogUtils.newWebLogger("changeApplyFlowStart.发起流程异常=DATA:" + JSON.toJSONString(entity) + ",异常信息:" + e).info();
        } catch (Exception e) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员！");
            BaseLogUtils.newWebLogger("changeApplyFlowStart.发起流程异常==DATA:" + JSON.toJSONString(entity) + ",异常信息:" + e).info();
        }
        return result;
    }

    /**
     * 获取请求参数
     *
     * @param request 请求
     * @return
     */
    private PrjPrdChangeApplyVO getRequestParamForChangeApply(HttpServletRequest request) throws BaseException {
        //获取参数
        String prjId = request.getParameter("prjId");
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");
        BaseLogUtils.newWebLogger("changeApplyFlowStart.getRequestParam.prjId:" + prjId + ",prjPrdDtlId:" + prjPrdDtlId).info();
        String cstId = request.getParameter("cstId");
        String cstNm = request.getParameter("cstNm");
        String prjTypCd = request.getParameter("prjTypCd");
        String paySchId = request.getParameter("paySchId");
        String paySchNo = request.getParameter("paySchNo");
        String lsCntNo = request.getParameter("lsCntNo");
        String cstMgrId = request.getParameter("cstMgrId");
        String cstMgrNm = request.getParameter("cstMgrNm");
        String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");
        String buOrgCd = request.getParameter("buOrgCd");
        //变更类型（PRJ0182）
        String changeTypeCd = request.getParameter("changeTypeCd");
        //资金占用天数
        String fundOccDays = request.getParameter("fundOccDays");
        //资金占用成本
        String fundOccCost = request.getParameter("fundOccCost");
        //应收款金额
        String recAmount = request.getParameter("recAmount");
        //备注
        String remark = request.getParameter("remark");
        //支付表类型
        String paySchTypCd = request.getParameter("paySchTypCd");

        //验证参数并赋值
        PrjPrdChangeApplyVO entity = new PrjPrdChangeApplyVO();
        if (StringUtils.isEmpty(prjId)) {
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "项目ID不能为空！");
        }
        if (StringUtils.isEmpty(paySchId)) {
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "支付表ID不能为空！");
        }
        if (StringUtils.isEmpty(paySchNo)) {
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "支付表号不能为空！");
        }
        if (StringUtils.isEmpty(prjPrdDtlId)) {
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "项目产品明细ID不能为空！");
        }
        if (StringUtils.isEmpty(changeTypeCd)) {
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "变更类型不能为空！");
        }
        entity.setPrjId(Long.valueOf(prjId));
        entity.setPaySchId(Long.valueOf(paySchId));
        entity.setPaySchNo(paySchNo);
        entity.setPrjPrdDtlId(Long.valueOf(prjPrdDtlId));
        entity.setChangeTypeCd(changeTypeCd);
        if (StringUtils.isNotEmpty(cstId)) {
            entity.setCstId(Long.valueOf(cstId));
        }
        if (StringUtils.isNotEmpty(cstNm)) {
            entity.setCstNm(cstNm);
        }
        if (StringUtils.isNotEmpty(prjTypCd)) {
            entity.setPrjTypCd(prjTypCd);
        }
        if (StringUtils.isNotEmpty(lsCntNo)) {
            entity.setLsCntNo(lsCntNo);
        }
        if (StringUtils.isNotEmpty(cstMgrId)) {
            entity.setCstMgrId(Long.valueOf(cstMgrId));
        }
        if (StringUtils.isNotEmpty(cstMgrNm)) {
            entity.setCstMgrNm(cstMgrNm);
        }
        if (StringUtils.isNotEmpty(cstMgrOrgCd)) {
            entity.setCstMgrOrgCd(cstMgrOrgCd);
        }
        if (StringUtils.isNotEmpty(buOrgCd)) {
            entity.setBuOrgCd(buOrgCd);
        }
        if (StringUtils.isNotEmpty(remark)) {
            entity.setRemark(remark);
        }
        if (StringUtils.isNotEmpty(fundOccDays)) {
            entity.setFundOccDays(Long.valueOf(fundOccDays));
        }

        try {
            //资金占用成本
            if (StringUtils.isNotEmpty(fundOccCost)) {
                entity.setFundOccCost(DecimalUtils.convertYuanToFen(Double.parseDouble(fundOccCost.trim().replace(",", ""))));
            }
            //应收款金额
            if (StringUtils.isNotEmpty(recAmount)) {
                entity.setRecAmount(DecimalUtils.convertYuanToFen(Double.parseDouble(recAmount.trim().replace(",", ""))));
            }
        } catch (NumberFormatException e) {
            throw new BaseException("金额转换异常！");
        }

        if (StringUtils.isNotEmpty(paySchTypCd)) {
            entity.setPaySchTypCd(paySchTypCd);
        }
        entity.setCrtTm(new Date());
        entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
        entity.setIsDel(BaseConstant.IS_YESNO_NO);
        entity.setIsHistory(BaseConstant.IS_YESNO_NO);
        return entity;
    }

    /**
     * 发起换车审批流程
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/changeForHCFlowStart.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object changeForHCFlowStart(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        BaseLogUtils.newLogger("changeForHCFlowStart.getRequest:{}", JSONObject.toJSONString(request.getParameterMap())).info();

        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "流程发起成功！");
        PrjPrdChangeApplyVO entity = null;
        try {
            String prjId = request.getParameter("prjId");
            String prjPrdDtlId = request.getParameter("prjPrdDtlId");
            String newPrjPrdDtlId = request.getParameter("newPrjPrdDtlId");
            String paySchId = request.getParameter("paySchId");
            String paySchNo = request.getParameter("paySchNo");
            String changeTypeCd = request.getParameter("changeTypeCd");
            String id = request.getParameter("id");

            if (StringUtils.isEmpty(id)) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "变更记录ID不能为空！");
            }
            if (StringUtils.isEmpty(prjId)) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "项目ID不能为空！");
            }
            if (StringUtils.isEmpty(paySchId)) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "支付表ID不能为空！");
            }
            if (StringUtils.isEmpty(paySchNo)) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "支付表号不能为空！");
            }
            if (StringUtils.isEmpty(prjPrdDtlId)) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "项目产品明细ID不能为空！");
            }
            if (StringUtils.isEmpty(changeTypeCd)) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "变更类型不能为空！");
            }
            if (changeTypeCd.equals(PrjPrdChangeApplyConstant.CHANGE_TYPE_CD_2)) {
                if (StringUtils.isEmpty(newPrjPrdDtlId)) {
                    throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "新产品明细ID不能为空！");
                }
            }
            entity = new PrjPrdChangeApplyVO();
            entity.setId(Long.valueOf(id));
            entity.setPrjId(Long.valueOf(prjId));
            entity.setPaySchId(Long.valueOf(paySchId));
            entity.setPaySchNo(paySchNo);
            entity.setPrjPrdDtlId(Long.valueOf(prjPrdDtlId));
            entity.setChangeTypeCd(changeTypeCd);
            entity.setNewPrjPrdDtlId(Long.valueOf(newPrjPrdDtlId));

            if (entity == null) {
                result = new DataResultVO(BaseConstant.IS_YESNO_NO, SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
                BaseLogUtils.newWebLogger("changeForHCFlowStart.发起流程==参数为空!" + "userNm:" + CurrentThreadContext.getCurrentUserName()).info();
                return result;
            }
            BaseLogUtils.newWebLogger("changeForHCFlowStart.发起流程Start=prjId:" + entity.getPrjId() + ",userNm:" + CurrentThreadContext.getCurrentUserName()).info();
            PrjPrdChangeApplyDTO prjPrdChangeApplyDTO = PrjPrdChangeApplyVOTransform.toDTO(entity);
            prjPrdChangeApplyDTO.setCurrentOrgCd(CurrentThreadContext.getCurrentOrgCd());
            prjPrdChangeApplyDTO.setCurrentBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
            prjPrdChangeApplyDTO.setCurrentUsrId(CurrentThreadContext.getCurrentUserId());
            prjPrdChangeApplyDTO.setCurrentUsrNm(CurrentThreadContext.getCurrentUserName());
            prjPrdChangeApplyDTO.setCurrentSysCd(CurrentThreadContext.getCurrentSysCd());
            DataResultDTO resultDTO = this.prjPrdChangeApplyApiService.addChangeForHCFlow(prjPrdChangeApplyDTO);
            BaseLogUtils.newLogger("changeForHCFlowStart.发起流程End=prjId:{},resultDTO:{},userNm:{}", entity.getPrjId(), JSON.toJSONString(resultDTO), CurrentThreadContext.getCurrentUserName()).info();
            result.setSuccess(resultDTO.getSuccess());
            result.setInfo(resultDTO.getInfo());
        } catch (BaseException e) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(e.getMessage());
            BaseLogUtils.newWebLogger("changeForHCFlowStart.发起流程异常=DATA:" + JSON.toJSONString(entity) + ",异常信息:" + e).info();
        } catch (Exception e) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员！");
            BaseLogUtils.newWebLogger("changeForHCFlowStart.发起流程异常==DATA:" + JSON.toJSONString(entity) + ",异常信息:" + e).info();
        }
        return result;
    }

    /**
     * 到换车审批流程附加信息页面
     */
    @RequestMapping(value = "/toAdditionalInfoPageByHC.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAdditionalInfoPageByHC(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.newLogger("到退车审批流程附加信息页面").setKeys("toAdditionalInfoPage", CurrentThreadContext.getCurrentUserName()).info();
        ModelAndView view = new ModelAndView("changeapply/prjPrdChangeApply/PrjPrdChangeAddHC");
        //业务主键
        String changeApplyId = request.getParameter("changeApplyId");
        //流程实例ID
        String proIntId = request.getParameter("processInstanceId");
        //任务ID
        String taskId = request.getParameter("taskId");
        //任务KEY
        String taskDefKey = request.getParameter("taskDefKey");
        //任务名称
        String taskNm = request.getParameter("taskNm");
        //流程名称
        String procNm = request.getParameter("procNm");
        //0:信审节点
        String isDetail = request.getParameter("isDetail");
        //核价员核价标识
        String isNeedPrice = request.getParameter("isNeedPrice");
        //是否详情：1.是 0.否 呈报人-0
        String detailFlag = request.getParameter("detailFlag");
        //权证归档标识：1 权证归档节点；2 合同管理员补充节点
        String arcInfoFlag = request.getParameter("arcInfoFlag");
        //是否可以审核上牌信息标识
        String checkSp = request.getParameter("checkSp");
        //是否可以审核抵押信息标识
        String checkDy = request.getParameter("checkDy");
        try {
            view.addObject("currentUsrId", CurrentThreadContext.getCurrentUserId());
            view.addObject("changeApplyId", changeApplyId);
            view.addObject("proIntId", proIntId);
            view.addObject("taskId", taskId);
            view.addObject("taskDefKey", taskDefKey);
            view.addObject("taskNm", taskNm);
            view.addObject("procNm", procNm);
            view.addObject("arcInfoFlag", arcInfoFlag);
            view.addObject("checkSp", checkSp);
            view.addObject("checkDy", checkDy);
            //是否在流程页面标识
            view.addObject("flowFlag", true);
            if ("0".equals(isDetail)) {
                view.addObject("isDetail", isDetail);
            } else {
                view.addObject("isDetail", 1);
            }
            if ("1".equals(isNeedPrice)) {
                view.addObject("isNeedPrice", isNeedPrice);
            } else {
                view.addObject("isNeedPrice", 0);
            }
            if ("0".equals(detailFlag)) {
                view.addObject("detailFlag", false);
            } else {
                view.addObject("detailFlag", true);
            }
            if (StringUtils.isEmpty(changeApplyId)) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "流程中业务主键为空.");
            }
            //查询退车申请信息
            BaseLogUtils.newServiceLogger("===换车审批流程查询付款信息Start===changeApplyId:" + changeApplyId).info();
            PrjPrdChangeApplyVO prjPrdChangeApplyVO = prjPrdChangeApplyService.selectById(Long.valueOf(changeApplyId));
            BaseLogUtils.newServiceLogger("===换车审批流程查询付款信息End===changeApplyId:" + changeApplyId + ",prjPrdChangeApplyVO:" + JSON.toJSONString(prjPrdChangeApplyVO)).info();

            if (prjPrdChangeApplyVO != null) {
                view.addObject("changeTypeCd", prjPrdChangeApplyVO.getChangeTypeCd());
                view.addObject("lsCntNo", prjPrdChangeApplyVO.getLsCntNo());
                view.addObject("prjPrdDtlId", prjPrdChangeApplyVO.getPrjPrdDtlId());
                Long paySchId = prjPrdChangeApplyVO.getPaySchId();
                view.addObject("paySchId", paySchId);
                //查询启用支付表
                BaseLogUtils.newLogger("===换车审批流程查询支付表信息Start===paySchId:{}", paySchId).info();
                PrjPrdPaySchMVO prjPrdPaySchMVO = this.prjPrdPaySchMService.selectById(paySchId);
                BaseLogUtils.newLogger("===换车审批流程查询支付表信息End===paySchId:{},vo:{}", paySchId, JSON.toJSONString(prjPrdPaySchMVO)).info();
                view.addObject("prjPrdPaySchMVO", prjPrdPaySchMVO);
                //查询已还期次
                Integer payPd = 0;
                PrjPrdPaySchDQueryCondition dQC = new PrjPrdPaySchDQueryCondition();
                List<Long> paySchIds = new ArrayList<>();
                paySchIds.add(Long.valueOf(paySchId));
                dQC.setPaySchIdList(paySchIds);
                List<PrjPrdPaySchDDTO> paidPayPdList = this.prjPaySchDApiService.searchPaidPayPdList(dQC);
                BaseLogUtils.newLogger("查询支付表信息：paySchId:{},paidPayPdList:{}", JSONObject.toJSONString(paySchIds), JSONObject.toJSONString(paidPayPdList)).info();
                if (CollectionUtils.isNotEmpty(paidPayPdList)) {
                    payPd = paidPayPdList.get(0).getPayPd();
                }
                view.addObject("payPd", payPd);
                //支付表状态
                PrjPrdDtlVO prjPrdDtlVO = this.prjPrdDtlService.selectById(prjPrdChangeApplyVO.getPrjPrdDtlId());
                if (prjPrdDtlVO != null && StringUtils.isNotEmpty(prjPrdDtlVO.getPrdStsCd())) {
                    Map<String, String> prjPrdStsCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), PrjPrdDtlConstant.CODE_PRJ_PRD_STS_CD);
                    view.addObject("prjPrdStsCd", prjPrdStsCdMap.get(prjPrdDtlVO.getPrdStsCd()));
                }
                //根据启用支付表ID查询付款信息
                CapPayInfoVO capPayInfoVO = null;
                BaseLogUtils.newLogger("===退车申请查询付款信息Start===paySchId:" + paySchId).info();
                List<CapPayInfoVO> capPayInfoVOS = this.capPayInfoService.selectListByEnabledPaySchId(Long.valueOf(paySchId));
                BaseLogUtils.newLogger("===退车申请查询付款信息End===paySchId:{},list:{}", paySchId, JSON.toJSONString(capPayInfoVOS)).info();
                if (CollectionUtils.isNotEmpty(capPayInfoVOS)) {
                    capPayInfoVO = capPayInfoVOS.get(0);
                }
                if (capPayInfoVO != null) {
                    //查询支付表明细信息
                    CapPayeeInfoQueryCondition qc = new CapPayeeInfoQueryCondition();
                    qc.setPayId(capPayInfoVO.getId());
                    List<String> purpCds = new ArrayList<>();
                    purpCds.add(CapPayeeInfoConstant.CODE_PURP_CD_00000008_1);
                    qc.setPurpCds(purpCds);
                    BaseLogUtils.newLogger("===换车申请查询收款信息Start===payId:{},qc:{}", capPayInfoVO.getId(), JSON.toJSONString(qc)).info();
                    List<CapPayeeInfoVO> capPayeeInfoVOS = this.capPayeeInfoService.searchList(qc);
                    BaseLogUtils.newLogger("===换车申请查询收款信息End===payId:{},size:{}", capPayInfoVO.getId(), capPayeeInfoVOS == null ? 0 : capPayeeInfoVOS.size()).info();
                    if (CollectionUtils.isNotEmpty(capPayeeInfoVOS)) {
                        CapPayeeInfoVO capPayeeInfoVO = capPayeeInfoVOS.get(0);
                        view.addObject("capPayeeInfoVO", capPayeeInfoVO);
                    }
                }
                view.addObject("capPayInfoVO", capPayInfoVO);
                Long newPrjPrdDtlId = prjPrdChangeApplyVO.getNewPrjPrdDtlId();
                if (newPrjPrdDtlId != null) {
                    //查询流程状态
                    SysFlowSHQueryCondition sysFlowSHQC = new SysFlowSHQueryCondition();
                    sysFlowSHQC.setDataId(prjPrdChangeApplyVO.getId());
                    sysFlowSHQC.setWordsInTheTable(CapPayInfoConstant.CAP_FLOW_S_H_CAP);
                    sysFlowSHQC.setSysCd(CurrentThreadContext.getCurrentSysCd());
                    sysFlowSHQC.setStatus(BaseConstant.IS_YESNO_YES);
                    BaseLogUtils.newLogger("===换车页面获取流程状态Start===applyId:{},qc:{}", prjPrdChangeApplyVO.getId(), JSON.toJSONString(sysFlowSHQC)).info();
                    List<SysFlowSHDTO> sysFlowSHDTOS = this.flowQueryApiService.searchFlowSHList(sysFlowSHQC);
                    BaseLogUtils.newLogger("===换车页面获取流程状态End===applyId:{},flowSHList:{}",  prjPrdChangeApplyVO.getId(), JSON.toJSONString(sysFlowSHDTOS)).info();
                    boolean noPassFlag = false;
                    if (CollectionUtils.isNotEmpty(sysFlowSHDTOS)) {
                        SysFlowSHDTO sysFlowSHDTO = sysFlowSHDTOS.get(0);
                        //审核不通过，查询已删除状态数据
                        if (sysFlowSHDTO != null && FlowConstant.FLOW_CHECK_STATE_NO_PASS.equals(sysFlowSHDTO.getAudStsCd())) {
                            noPassFlag = true;
                        }
                    }
                    view.addObject("noPassFlag", noPassFlag);
                    PrjPrdChangeApplyQC prjPrdChangeApplyQC = new PrjPrdChangeApplyQC();
                    prjPrdChangeApplyQC.setPrjPrdDtlId(newPrjPrdDtlId);
                    PrjPrdChangeApplyFlowVO newDtlVO = this.prjPrdChangeApplyService.getPrdChangeDetail(prjPrdChangeApplyQC, noPassFlag);
                    BaseLogUtils.newLogger("===换车申请页面详细信息===newPrjPrdDtlId:{},newDtlVO:{}", newPrjPrdDtlId, JSON.toJSONString(newDtlVO)).info();
                    view.addObject("newDtlVO", newDtlVO);
                }
                view.addObject("newPrjPrdDtlId", newPrjPrdDtlId);
                if (prjPrdChangeApplyVO.getPrjId() != null) {
                    //获取原项目的立项流程实例ID
                    SysFlowSHQueryCondition qc = new SysFlowSHQueryCondition();
                    qc.setDataId(prjPrdChangeApplyVO.getPrjId());
                    qc.setWordsInTheTable(PrjBscInfoConstant.PRJ_FLOW_S_H_PRJ);
                    qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
                    qc.setBusTyp(FlowConstant.FLOW_MODEL_TYP_PRJ_1);
                    qc.setStatus(BaseConstant.IS_YESNO_YES);
                    BaseLogUtils.newLogger("===换车页面获取原项目的立项流程实例ID===newPrjPrdDtlId:{},qc:{}", newPrjPrdDtlId, JSON.toJSONString(qc)).info();
                    List<SysFlowSHDTO> flowSHList = this.flowQueryApiService.searchFlowSHList(qc);
                    BaseLogUtils.newLogger("===换车页面获取原项目的立项流程实例ID===newPrjPrdDtlId:{},flowSHList:{}", newPrjPrdDtlId, JSON.toJSONString(flowSHList)).info();
                    if (CollectionUtils.isNotEmpty(flowSHList)) {
                        SysFlowSHDTO sysFlowSHDTO = flowSHList.get(0);
                        String pInstId = sysFlowSHDTO.getPInstId();
                        view.addObject("prjPInstId", pInstId);
                    }
                }
            }
        } catch (NumberFormatException e) {
            BaseLogUtils.newLogger("===toAdditionalInfoPageByHC跳转换车审批流程页面BASE异常===Detail:" + e).setBussinessId(changeApplyId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
            e.printStackTrace();
        } catch (Exception e) {
            BaseLogUtils.newLogger("===toAdditionalInfoPageByHC跳转换车审批流程页面BASE异常===Detail:" + e).setBussinessId(changeApplyId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
            e.printStackTrace();
        }
        BaseLogUtils.newLogger("toAdditionalInfoPageByHC换车审批流程页面.返回前台.view:" + JSON.toJSONString(view)).info();
        return view;
    }
}
